package com.ws.common;

import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author ：ws
 * @date ：Created in 2023/10/23 15:46
 * @description：TODO
 * @modified By：
 * @version: 1.0.0
 */
public class PaasPage<T> {
    private static final long serialVersionUID = 1L;
    private List<T> content;
    private long total;
    private int limit;
    private int page;

    public PaasPage() {
    }

    public PaasPage(List<T> content, long total, int limit, int page) {
        this.content = content;
        this.total = total;
        this.limit = limit;
        this.page = page;
    }

    public <R> PaasPage<R> mapContent(Function<? super T, ? extends R> mapper) {
        List targetContent = (List) this.getContent().stream().map(mapper).collect(Collectors.toList());
        return new PaasPage(targetContent, this.total, this.limit, this.page);
    }

    public List<T> getContent() {
        return this.content;
    }

    public void setContent(List<T> content) {
        this.content = content;
    }

    public long getTotal() {
        return this.total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public int getLimit() {
        return this.limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }

    public int getPage() {
        return this.page;
    }

    public void setPage(int page) {
        this.page = page;
    }
}
